package com.example.wanandroid_copy2.ui.login.data.repository

import androidx.lifecycle.MutableLiveData
import com.example.wanandroid_copy2.common.BaseObserver
import com.example.wanandroid_copy2.common.BaseResponse
import com.example.wanandroid_copy2.common.api.ApiRepository
import com.example.wanandroid_copy2.common.network.State
import com.example.wanandroid_copy2.common.utils.execute
import com.example.wanandroid_copy2.ui.login.data.model.LoginRsp
import com.example.wanandroid_copy2.ui.login.data.model.RegisterRsp

class AccountRepository(val loadState: MutableLiveData<State>) : ApiRepository() {


    fun login(userName :String,password :String,liveData: MutableLiveData<BaseResponse<LoginRsp>>){
        apiService.getLogin(userName,password).execute(BaseObserver(liveData,loadState,this))
    }

    fun register(userName: String,password: String,repassword :String ,liveData: MutableLiveData<BaseResponse<RegisterRsp>>){
        apiService.getRegister(userName,password,repassword).execute(BaseObserver(liveData,loadState,this))
    }

}